import platform
import os

system = platform.system() + '_' + platform.machine()

sharedLibExt = 'so'

if platform.system() == 'Darwin':
	sharedLibExt = 'dylib'

env = Environment()

classes = env.Java(target='classes', source='src')

# Copy the native lib into 'classes' so it gets included in the jar file.
Command('classes/libphnq_babel.'+sharedLibExt, 'libphnq_babel.'+sharedLibExt, Copy('$TARGET', '$SOURCE'))

# Archive the default resources in a jar file and copy it into 'classes' so it gets included in the jar file.
AlwaysBuild(env.Jar(target='phnq_resources.jar', source='../../phnqlets/resources', JARCHDIR=Dir('../../phnqlets/resources')))
Command('classes/phnq_resources.jar', 'phnq_resources.jar', Copy('$TARGET', '$SOURCE'))

env.Jar(target='phnq_babel.jar', source='classes', JARCHDIR=Dir('classes'))

env.JavaH(target='native', source=classes)

env['LIBS'] = ['boost_thread-mt', 'boost_regex-mt', 'expat', 'z', 'webkit-1.0'];
env['LIBPATH'] = ['../../kit', '../../uth', '../../phnqlets', '/opt/local/lib', '../../webkit.tmp/lib'];
env['CPPPATH'] = [
	'../../kit/src',
	'../../uth/src',
	'../../phnqlets/src',
	os.environ['JAVA_HOME'] + '/include',
	os.environ['JAVA_HOME'] + '/include/' + platform.system().lower(),
	'/usr/include/webkit-1.0',
	'/usr/local/include/webkit-1.0',
	'/opt/local/include',
	'../../webkit.tmp/include'
];

env.SharedLibrary('phnq_babel',[
	Glob('native/*.cc'),
	Glob('../../kit/src/*.cc'),
	Glob('../../kit/src/log/*.cc'),
	Glob('../../kit/src/xml/*.cc'),
	Glob('../../kit/src/compression/*.cc'),
	Glob('../../phnqlets/src/*.cc'),
	Glob('../../uth/src/*.cc'),
	Glob('../../uth/src/types/*.cc'),
	Glob('../../uth/src/impl/*.cc')
])
